<?php
include "../../public/common/config.php";
//$sql = "select shop.*,brand.name bname,class.name cname from shop,brand,class where brand.class_id = class.id and shop.brand_id = brand.id";
$sql = "select shop.*,brand.name bname,class.name cname from shop left join brand on(shop.brand_id = brand.id) left join class on(brand.class_id = class.id)";
$result = mysql_query($sql);
//print_r($result);
?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<!--<meta name="viewport" content="width=divice-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />-->
		<script src="https://cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></script>
		<link rel="stylesheet" type="text/css" href="../public/css/common.css"/>
		<title></title>
	</head>
	<body>
		<table>
			<tr><th>编号</th><th>名称</th><th>图片</th><th>价格</th><th>库存</th><th>货架</th><th>品牌</th><th>分类</th><th>修改</th><th>删除</th></tr>
			<?php
			while($row = mysql_fetch_assoc($result)){
				echo "<tr>";
				echo "<td>{$row['id']}</td>";
				echo "<td>{$row['name']}</td>";
				echo "<td><img src='../public/uploads/{$row['img']}' width='50' /></td>";
				echo "<td>{$row['price']}</td>";
				echo "<td>{$row['stock']}</td>";
//				echo "<td>{$row['shelf']}</td>";
				if($row['shelf']){
					echo "<td>上架</td>";
				}else{
					echo "<td>下架</td>";
				}
				echo "<td>{$row['bname']}</td>";
				echo "<td>{$row['cname']}</td>";
				echo "<td><a href='edit.php?id={$row['id']}'>修改</a></td>";
				echo "<td><a href='delete.php?id={$row['id']}&img={$row['img']}'>删除</a></td>";
				echo "</tr>";
			}	
			?>
			
		</table>
	</body>
	
</html>
